<?php if($orderInfo['class_id']!=1){?>
<div class="clearfix user-center-head">
  <strong class="pull-left normal"><?php echo L('order_sn');?>: <?php echo $orderInfo['order_sn']; ?></strong>
  <?php if ($orderInfo['payment_status'] == OrderModel::PAY_UNPAYED && in_array($orderInfo['order_status'], array(OrderModel::ORDER_UNCONFIRMED ,OrderModel::ORDER_CONFIRMED))): ?>
    <a href="<?php echo url('order/order_edit','oid='.$orderInfo['id']);?>" class="btn pull-right"><?php echo L('editorderinfo');?></a>
  <?php elseif($orderInfo['order_status']==OrderModel::ORDER_CONFIRMED && in_array($orderInfo['shipping_status'], array(OrderModel::SHIPPING_SHIPPED ,OrderModel::SHIPPING_SHIPPED_PART))):?>
    <a href="<?php echo url('order/order_edit_status', array('oid' => $orderInfo['id'], 'status' => OrderModel::ORDER_COMPLETE));?>" class="btn pull-right"><?php echo L('confrim_order');?></a>
  <?php endif;?>

  <?php if($orderInfo['car_type'] && $orderInfo['payment_status'] == OrderModel::PAY_PAYED && $orderInfo['order_status'] !=2):?>
    <?php if($orderInfo['pay_return']){?>
      <?php echo $orderInfo['return_status'];?>
        <?php }else{?>
          <?php if($orderInfo['productList'][0]['refund']){?>
          <a href="javascript:confirmurl('<?php echo url('order/order_refund','oid='.$orderInfo['id']);?>', <?php echo L('confirm_to_apply_refund');?>)" class="btn pull-right"><?php echo L('application_for_drawback');?></a>
          <?php }else{?>
          <a href="javascript:confirmurl('<?php echo url('order/order_refund','oid='.$orderInfo['id']);?>', <?php echo L('confirm_to_apply_refund');?>, <?php echo L('if_he_will_notbe_deposit');?>【<?php echo currency($orderInfo['productList'][0]['yufu_price']);?>】<?php echo L('return');?>')" class="btn pull-right"><?php echo L('application_for_drawback');?></a>
      <?php }?>
    <?php }?>
  <?php endif;?>
</div>
<!--订单状态-->
<div class="order-status">
  <?php
    $step = 0;
    if($orderInfo['start_time']){
      if($orderInfo['payment_time']){
        $step = 1;
        $orderInfo['shipping_action_time'] = M('orders_log')->where(array('order_id'=>$orderInfo['id'],'shipping_status'=>99))->getField('action_time');
        if($orderInfo['shipping_time']){
          if($orderInfo['end_time']){
            $step = 4;
          }else{
            $step = 3;
          }
        }else{
          if($orderInfo['shipping_action_time']) $step = 2;
        }
      }
    }
  ?>
  <ul class="clearfix status-diagram">
    <li class="current">
      <i class="circle"></i>
      <span class="bar"></span>
      <i class="triangle-right"></i>
    </li>
    <li<?php if($step >= 1):?> class="current"<?php endif;?>>
      <i class="circle"></i>
      <span class="bar"></span>
      <i class="triangle-right"></i>
    </li>
    <li<?php if($step >= 2):?> class="current"<?php endif;?>>
      <i class="circle"></i>
      <span class="bar"></span>
      <i class="triangle-right"></i>
    </li>
    <li<?php if($step >= 3):?> class="current"<?php endif;?>>
      <i class="circle"></i>
      <span class="bar"></span>
      <i class="triangle-right"></i>
    </li>
    <li class="last<?php if($step >= 4):?> current<?php endif;?>">
      <i class="circle"></i>
    </li>
  </ul>
  <ul class="clearfix">
    <?php if($orderInfo['order_status'] == OrderModel::ORDER_CANCELED): ?>
    <li>
      <div><?php echo L('_cancelled_');?></div>
      <div><?php echo date('Y-m-d',$orderInfo['update_time']);?></div>
      <div><?php echo date('H:i:s',$orderInfo['update_time']);?></div>
    </li>
    <?php else: ?>
    <li>
      <div><?php echo L('completed_order');?></div>
      <div><?php echo date('Y-m-d',$orderInfo['start_time']);?></div>
      <div><?php echo date('H:i:s',$orderInfo['start_time']);?></div>
    </li>
    <?php endif; ?>
    <li>
      <div><?php echo L('_PAY_PAYED_');?></div>
      <?php if($orderInfo['payment_time']):?>
      <div><?php echo date('Y-m-d',$orderInfo['payment_time']);?></div>
      <div><?php echo date('H:i:s',$orderInfo['payment_time']);?></div>
      <?php endif;?>
    </li>
    <li>
      <div><?php echo L('making');?></div>
      <?php if($orderInfo['shipping_action_time']):?>
      <div><?php echo date('Y-m-d',$orderInfo['shipping_action_time']);?></div>
      <div><?php echo date('H:i:s',$orderInfo['shipping_action_time']);?></div>
      <?php endif;?>
    </li>
    <li>
      <div><?php echo L('_SHIPPING_SHIPPED_');?></div>
      <?php if($orderInfo['shipping_time']):?>
      <div><?php echo date('Y-m-d',$orderInfo['shipping_time']);?></div>
      <div><?php echo date('H:i:s',$orderInfo['shipping_time']);?></div>
      <?php endif;?>
    </li>
    <li class="last">
      <div><?php echo L('_ACCOUNT_COMPLETED_');?></div>
      <?php if($orderInfo['end_time']):?>
      <div><?php echo date('Y-m-d',$orderInfo['end_time']);?></div>
      <div><?php echo date('H:i:s',$orderInfo['end_time']);?></div>
      <?php endif;?>
    </li>
  </ul>
</div>
    <!--收货人信息-->
    <div class="user-center-head"><?php echo L('consignee');?></div>
    <div class="consigneeinfo">
      <div><?php echo isset($orderInfo['delivery_first_name']) ? $orderInfo['delivery_first_name'] : ''; ?>, <?php echo isset($orderInfo['delivery_last_name']) ? $orderInfo['delivery_last_name'] : ''; ?>/<?php echo isset($orderInfo['delivery_address']) ? $orderInfo['delivery_address'] : ''; ?>,<?php echo isset($orderInfo['delivery_city']) ? $orderInfo['delivery_city'] : ''; ?>,<?php echo isset($orderInfo['delivery_province']) ? $orderInfo['delivery_province'] : ''; ?>,<?php echo isset($orderInfo['delivery_country']) ? $orderInfo['delivery_country'] : ''; ?>/<?php echo isset($orderInfo['delivery_phone']) ? $orderInfo['delivery_phone'] : ''; ?></div>
      <div><?php echo isset($orderInfo['delivery_email']) ? $orderInfo['delivery_email'] : ''; ?>/<?php echo isset($orderInfo['delivery_postcode']) ? $orderInfo['delivery_postcode'] : ''; ?></div>
    </div>
    <!--备注-->
    <div class="user-center-head"><?php echo L('remark');?></div>
    <div class="consigneeinfo">
      <div><?php echo isset($orderInfo['remark']) ? $orderInfo['remark'] : ''; ?></div>
    </div>
    <!--配送方式-->
    <div class="user-center-head"><?php echo L('shipping_method')?></div>
    <div class="consigneeinfo">
      <?php echo L('shippingmethod');?>:
      <strong><?php echo isset($orderInfo['shipping_method_name']) ? $orderInfo['shipping_method_name'] : null ?> (<?php echo $orderInfo['shipping_method'];?><?php echo !empty($orderInfo['shipping_no']) ? ':'.$orderInfo['shipping_no'] : '';?>)</strong>
      <?php if($orderInfo['car_type'] && $orderInfo['payment_status'] == OrderModel::PAY_PAYED && $orderInfo['order_status'] !=2):?>
        <?php if($orderInfo['pay_return']){?>
        <?php echo $orderInfo['return_status'];?>
          <?php }else{?>
            <?php if($orderInfo['productList'][0]['refund']){?>
              <a href="javascript:confirmurl('<?php echo url('order/order_refund','oid='.$orderInfo['id']);?>', <?php echo L('confirm_to_apply_refund');?>)" class="pull-right"><?php echo L('user_changer_order_details')?></a>
              <?php }else{?>
              <a href="javascript:confirmurl('<?php echo url('order/order_refund','oid='.$orderInfo['id']);?>', <?php echo L('confirm_to_apply_refund');?>, <?php echo L('if_he_will_notbe_deposit');?>【<?php echo currency($orderInfo['productList'][0]['yufu_price']);?>】<?php echo L('return');?>')" class="pull-right"><?php echo L('user_changer_order_details')?></a>
          <?php }?>
        <?php }?>
      <?php endif;?>
    </div>
<?php }?>
<form action="/user/update_order/oid/<?php echo $_GET['oid']?>" method="post">
  <!--支付方式-->
  <div class="user-center-head"><?php echo L('payment_method')?></div>
  <?php if($orderInfo['payment_status'] != OrderModel::PAY_PAYED):?>
  <div class="order-payment js-payment-method">
    <input type="hidden" name="payment_method" value="<?php echo $orderInfo['payment_method'];?>" />
    <ul class="clearfix">
      <?php
      if(isset($paymentList) && $paymentList):
          $i=1;
          foreach ($paymentList as $k => $payment) :
              if (!$payment['status']) continue;
              ?>
              <li class="col-md-6 col-sm-6<?php if ($payment['name'] == $orderInfo['payment_method']){?> selected<?php } ?>" data-info="<?php echo $payment['name'];?>">
                <div>
                  <p class="text"><?php if($payment['name'] =="Visabill"){echo L('_credit_');}elseif($payment['name'] == "Paypal"){echo L('_paypal_');}elseif($payment['name'] == "Worldpay"){echo L('_worldpay_');}elseif($payment['name'] == "Alipay"){echo L('_alipay_');};?></p>
                  <img src="/statics/front/images/cart/<?php if($payment['name'] =="Visabill"){echo "visa";}elseif($payment['name'] == "Paypal"){echo "paypal";}elseif($payment['name'] == "Worldpay"){echo "worldpay";}elseif($payment['name'] == "Alipay"){echo "alipay";};?>.png" alt="<?php echo isset($payment['name']) ? $payment['name'] : null ;?>" />
                  <i class="mark"></i>
                </div>
              </li>
              <?php
              $i++;
          endforeach;
      endif;
      ?>
    </ul>
  </div>
  <?php else:?>
  <div class="consigneeinfo">
    <?php echo L('payment_method');?>:
    <strong><?php echo isset($orderInfo['payment_method_name']) ? $orderInfo['payment_method_name'] : null?></strong>
  </div>
  <?php endif;?>

  <!--订单商品-->
  <table class="order-goods">
    <tr>
      <th width="10%"><?php echo L('product_image')?></th>
      <th width="40%"><?php echo L('order_goods');?></th>
      <th width="10%"><?php echo L('goods_price');?></th>
      <th width="10%">数量</th>
      <th width="10%">总金额</th>
      <th width="20%"><?php echo L('figure_data');?></th>
    </tr>
    <?php
      if (isset($orderInfo['productList'])):
      foreach ($orderInfo['productList'] as $k => $product):
        if(in_array($product['product_id'],$order_down_product))
          $product['display'] = 0;
        else
          $product['display'] = 1;
    ?>
    <tr<?php if($product['display']==0):?> class="sold-out"<?php endif;?>>
      <td align="center"><img src="<?php echo $product['small_img'] ?>" alt="goods image" width="50" height="50" /></td>
      <td align="center">
        <a href="<?php echo url('product/'.$product['product_id'].'-'.generateUrl_un($product['product_name']));?>" class="link-gray"><?php echo $product['product_name'] ?></a><br />
        <?php if($product['custom_type']==2):?>
        <span class="check-options js-check-options"><?php echo L('_change_the_customization_options_');?></span>
        <div class="hide align-left pt2x pb2x custom-list js-custom-list">
          <?php
            $size_type = $product['size_type'];
            $attributeList = $product['attributeList'];
          ?>
          <?php include THEMES_PATH . 'public/check_options.phtml'; ?>
        </div>
        <?php endif;?>
      </td>
      <?php if($product['display'] == 0 ):?>
      <td colspan="4"><?php echo L('SOLD_OUT')?><!--sold out--></td>
      <?php else:?>
      <td align="center"><?php echo currency(($product['total_amount']-$product['pants_price']*$product['pants_qty'])/$product['qty']);?></td>
      <td align="center"><?php echo $product['qty'] ?></td>
      <td align="center"><?php echo currency($product['total_amount']-$product['pants_price']*$product['pants_qty']);?></td>
      <td align="center">
        <?php if($product['model_id'] == 25):?> <!-- 鞋子尺码 -->
          <?php
            $attr_id = 161;
            $attr = $attributeList[$attr_id];
          ?>
          <?php foreach ($attr['values'] as $attrv):?>
          <?php if($attr['default'] == $attrv['product_attr_id']):?>
          <?php echo $attrv['label'];?>:
          <?php endif;?>
          <?php endforeach;?>
          <?php
              $attr_id = 162;
              $attr = $attributeList[$attr_id];
          ?>
          <?php if(isset($attr['default']) && $attr['default']){echo $attr['default'];} ?>
        <?php endif;?>

        <?php if($product['model_id'] != 25){?><!-- 非鞋子的尺码 -->
          <?php if($product['measure_id']):?>
            <?php
              $measureInfo = AttributeModel::get_user_measure_info($product['measure_id']);
              if($measureInfo['m_status'] == 5):
            ?>
              <?php foreach(unserialize($measureInfo['measure_data']) as $mskey=>$msval):?>
              <?php echo MeasureModel::msizedataShow($mskey);?>:<strong class="text-bold"><?php echo $msval;?></strong><br />
              <?php endforeach;?>
            <?php else:?>
            <?php echo $measureInfo['measure_name'];?>
            <?php endif;?>
          <?php endif;?>
        <?php }?>
      </td>
      <?php endif;?>
    </tr>
    <?php if($product['pants_qty'] > 0):?>
      <tr>
        <td></td>
        <td><?php echo L('AdditionalPants'); ?></td>
        <td><?php echo currency($product['pants_price']);?></td>
        <td><?php echo $product['pants_qty'] ?></td>
        <td><?php echo currency($product['pants_price']*$product['pants_qty']);?></td>
        <td></td>
      </tr>
      <?php endif;?>
    <?php
    endforeach;
    endif;
    ?>
    <?php if (isset($orderInfo)): ?>
    <tr>
      <td colspan="6" align="right" class="text"><?php echo L('all_goods_total');?> : <?php echo isset($orderInfo['product_amount']) ? currency($orderInfo['product_amount']) : ''; ?>
          + <?php echo L('shipping_fee');?> : <?php echo currency($orderInfo['shipping_fee']);?>
          <?php if($orderInfo['payment_fee']){?> + 附加费: <?php echo currency($orderInfo['payment_fee']);?><?php }?></td>
    </tr>
    <?php if($orderInfo['surplus_money']){?>
    <tr>
      <td colspan="6" align="right" class="text">
        - <?php echo L('usebalance');?> : <?php echo currency($orderInfo['surplus_money']);?>
        <input type="hidden" name="surplus_money02" id="input_surplus_money" value="<?php echo $orderInfo['surplus_money'];?>" />
      </td>
    </tr>
    <?php }?>
      <?php if($orderInfo['coupon_money']){?>
    <tr>
      <td colspan="6" align="right" class="text">- <?php echo L('order_discount_you_save')?> : <?php echo currency($orderInfo['hongbao_money']+$orderInfo['coupon_money']);?></td>
    </tr>
    <?php }?>
    <?php endif ?>
    <tr>
      <td colspan="6" align="right" class="text"><?php echo L('paid_amount');?> : <strong id="pay_amount"><?php if (isset($orderInfo['pay_amount'])) echo currency($orderInfo['pay_amount']);?></strong></td>
    </tr>
    <?php if($orderInfo['order_status'] == OrderModel::ORDER_UNCONFIRMED && $orderInfo['payment_status'] == OrderModel::PAY_UNPAYED && $user_money>0 && !$order_down_product):?>
    <tr>
      <td colspan="6" align="right"><?php echo L('balance_amount');?>: <strong id="user_money_1"><?php echo currency($user['user_money'])?></strong></td>
    </tr>
    <tr>
      <td colspan="6" align="right" class="text use-balance">
        <label><?php echo L('use_balance_to_pay');?> <input type="checkbox" onclick="get_user_money()" value="1" name="is_user_money" id="is_user_money" /></label>
      </td>
    </tr>
    <?php endif;?>
  </table>
  <?php if($orderInfo['order_status'] == OrderModel::ORDER_UNCONFIRMED && $orderInfo['payment_status'] == OrderModel::PAY_UNPAYED && !$order_down_product):?>
  <div class="align-right">
    <input type="hidden" name="surplus_money" id="surplus_money" value="0">
    <input type="hidden" name="info_user_money" id="info_user_money" value="<?php echo $user_money; ?>">
    <input type="hidden" name="info_pay_amount" id="info_pay_amount" value="<?php echo $orderInfo['pay_amount']; ?>">
    <input type="submit" class="pay_button" value="<?php echo L('_PAY_NOW_'); ?>">
  </div>
  <?php endif;?>
</form>
<script>
$(function() {
  var use_balance_flag = $('#is_user_money').is(":checked");
  if(use_balance_flag == true) {
    get_user_money();
  }

  $('.js-payment-method').on('click', 'li', function() {//选择支付方式
    var $this = $(this);
    $this.closest('.js-payment-method').find('input[type=hidden]').val($this.data('info'));
    $this.addClass('selected').siblings().removeClass('selected');
  });
});

function confirmurl(url, message) {
  if (confirm(message)) {
    redirect(url);
  }
}

function redirect(url) {
  location.href = url;
}

function get_user_money() {
  var use_balance_flag = $('#is_user_money').is(":checked");
  var user_money = parseFloat($('#info_user_money').val());
  var pay_amount = parseFloat($('#info_pay_amount').val());
  var surplus_money = 0;

  if (use_balance_flag == true) {
    if(user_money > 0 && user_money < pay_amount ){
      pay_amount =  pay_amount - user_money;
      surplus_money = user_money;
      user_money = 0;
    } else if (user_money > 0 && user_money > pay_amount) {
      user_money = user_money - pay_amount;
      surplus_money = pay_amount;
      pay_amount = 0;
    }

    $.ajax({
      url:'/public/paymentc/price/'+pay_amount,
      type:'get',
      error:function() {
        alert('error');
      },
      success:function(data) {
        $('#pay_amount').html(data);
      }
    });
    $.ajax({
      url:'/public/paymentc/price/'+user_money,
      type:'get',
      error:function() {
        alert('error');
      },
      success:function(data) {
        $('#user_money_1').html(data);
      }
    });
  } else {
    $.ajax({
      url:'/public/paymentc/price/'+pay_amount,
      type:'get',
      error:function() {
        alert('error');
      },
      success:function(data) {
        $('#pay_amount').html(data);
      }
    });
    $.ajax({
      url:'/public/paymentc/price/'+user_money,
      type:'get',
      error:function() {
        alert('error');
      },
      success:function(data) {
        $('#user_money_1').html(data);
      }
    });
  }

  $('#surplus_money').val(surplus_money);
}
</script>
